import { defineStore, createPinia } from "pinia";
import { appFace } from "../interface";
import piniaPersistConfig from "@/config/piniaPersist";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";

export const app = defineStore({
	// id: 必须的，在所有 Store 中唯一
	id: "appFace",
	// state: 返回对象的函数
	state: (): appFace => ({
		// custom 自定义
		custom: "",
    }),
	getters: {},
	actions: {
		// setCustom 自定义
		async setCustom(custom: string) {
			this.custom = custom;
		},
	},
	persist: piniaPersistConfig("appFace")
});

// piniaPersist(持久化)
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

// 使用示例
/* 
* 页面引入： import { app } from "@/store/modules";
*/

export default pinia;
